﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using BookManage.BLL;
using BookManage.Model;

namespace BookManage
{
    public partial class frmMdyPwd : Form
    {
        Reader reader=frmLogin.reader;
        private Reader readerPwd = new Reader();
        private ReaderAdmin readerBLL = new ReaderAdmin();
        public frmMdyPwd()
        {
            InitializeComponent();
        }

        private void btnMdf_Click(object sender, EventArgs e)
        {
            if (txtOpwd.Text == "" || txtNpwd.Text == "" || txtCpwd.Text == "")
            {
                MessageBox.Show("请输入完整！");
            }
            else if (txtNpwd.Text != txtCpwd.Text)
            {
                    MessageBox.Show("两次密码输入不一致！");
            }
            else if(reader.rdPwd == txtNpwd.Text)
            {
                MessageBox.Show("新密码跟旧密码相同！请重新设计");
                txtNpwd.Clear();
                txtCpwd.Clear();
                txtCpwd.Focus();
            }
            else
            {
                readerPwd.rdID = reader.rdID;
                readerPwd.rdPwd = txtNpwd.Text.Trim();
                readerBLL.ChangePwd(readerPwd);
                MessageBox.Show("修改成功，下次登录时请使用新密码登录！");
            }
        }

        private void btnBack_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
